<?php

namespace app\admin\model\booking;

use think\Model;

class Teasing extends Model
{

    // 表名
    protected $name = 'booking_teasing';

    // 自动写入时间戳字段
    protected $autoWriteTimestamp = 'int';

    // 定义时间戳字段名
    protected $createTime = 'createtime';
    protected $updateTime = 'updatetime';
    protected $deleteTime = false;

    // 追加属性
    protected $append = [

    ];

    public static function init()
    {
        self::afterDelete(function ($row) {
            if ($row['pid']) {
                \addons\booking\model\Teasing::where('id', $row['pid'])->setDec('comments');
            }
        });
    }

    public function User()
    {
        return $this->belongsTo('\app\common\model\User', 'user_id', 'id', [], 'LEFT');
    }

    public function replay()
    {
        return $this->hasMany('Teasing', 'pid', 'id', [], 'LEFT');
    }

}
